package net.shenru.server;

import net.shenru.encogs.EncogChief;
import net.shenru.encogs.EncogTask;
import net.shenru.os.utlis.SrLog;
import android.content.Context;

/**
 * 爬虫服务。初始化爬虫任务，开启爬虫
 */
public class EncogServer implements SrServer {
	private static final String TAG = EncogServer.class.getSimpleName();
	
	private static EncogServer instance;
	private static Context context;
	private EncogTask currentTask;

	private EncogServer() {
		currentTask = null;
	};

	public static synchronized EncogServer getInstance(Context context) {
		if (instance == null) {
			instance = new EncogServer();
		}
		return instance;
	}


	public void run() {
		SrLog.i(TAG, "添加一个爬虫到服务");
		EncogChief chief = EncogChief.getInstance(context);
		chief.run(currentTask);
	}

	public EncogTask getTask() {
		//TODO 买庄
		return null;
	}

	public void setTaskBus(EncogTask task) {
		currentTask = task;
	}

}
